package com.compass.doctor.ui.patient.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutNewPatientChildItemBinding
import com.compass.doctor.databinding.LayoutPatientItemBinding
import com.compass.doctor.ui.patient.PatientDetailsActivity
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.ext.gone
import com.compass.framework.ext.onClick
import com.compass.framework.ext.visible
import com.compass.framework.glide.setUrlCircle
import com.compass.framework.model.DrugItem
import com.compass.framework.model.PatientInfo
import com.compass.framework.model.Tag
import com.compass.framework.utils.getDrawableResource

/**
 * Description： 新的患者ItemAdapter
 * Date:2023/12/14 13:43
 */
class NewPatientChildrenAdapter(private var mContext: Context) : BaseRecyclerViewAdapter<PatientInfo, LayoutNewPatientChildItemBinding>() {


    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutNewPatientChildItemBinding>,
        item: PatientInfo?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvName.text = item.name
            tvAge.text = item.patientAge
            ivHead.setUrlCircle(item.avatar)
            ivSex.background= if (item.sex==1) getDrawableResource(R.mipmap.icon_male) else  getDrawableResource(
                R.mipmap.icon_female)
            tvAdd.onClick {

                PatientDetailsActivity.start(mContext, item.id)
            }


        }
    }

    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutNewPatientChildItemBinding {
        return LayoutNewPatientChildItemBinding.inflate(layoutInflater, parent, false)
    }
}